<template>
  <div class="main">
    <div class="main_head">审核详情</div>
    <el-form :model="dataForm" ref="dataForm" label-position="left" label-width="auto" class="dataForm">
      <div class="dataForm_flex">
        <div class="form_item"><span class="auditD">提交时间：{{this.dataForm.createTime}}</span></div>
        <div class="form_item"><span class="auditD">提交来源：{{this.dataForm.source}}</span></div>
        <div class="form_item"><span class="auditD">状态：</span>
          <span v-if="this.dataForm.status == 0" class="auditD">待审核</span>
          <span v-if="this.dataForm.status == 1" class="auditD">已通过</span>
          <span v-if="this.dataForm.status == -1" class="auditD">拒绝通过</span>
        </div>
      </div>
      <div class="dataForm_flex">
        <div class="form_item" v-if="this.dataForm.status == -1" style="margin-top: 25px;"><span
            class="auditD">拒绝原因：<span style="font-weight: bold; color: red;">{{this.dataForm.opinion}}</span></span></div>
      </div>
      <el-divider></el-divider>
      <div class="dataForm_flex">
        <el-form-item label="酒企名称" prop="name">
          <el-input class="form_item" :disabled="true" maxlength="50" v-model="dataForm.name"></el-input>
        </el-form-item>
        <el-form-item label="法人" prop="legalPerson">
          <el-input class="form_item" :disabled="true" maxlength="50" v-model="dataForm.legalPerson"></el-input>
        </el-form-item>
      </div>
      <div class="dataForm_flex">
        <el-form-item label="联系人" prop="linkman">
          <el-input class="form_item" :disabled="true" maxlength="50" v-model="dataForm.linkman"></el-input>
        </el-form-item>
        <el-form-item label="联系方式" prop="contactWay">
          <el-input class="form_item" :disabled="true" type="number" v-model="dataForm.contactWay"></el-input>
        </el-form-item>
      </div>

      <div class="dataForm_img">
        <div class="img_left">
          <div>
            <div class="red">*</div>
            <div class="text">基本存款账户信息：</div>
          </div>
          <div class="img">
            <img-upload class="img-upload" v-model="dataForm.basicAccount" style="windth:20px;height: 20px;"/>
          </div>
        </div>
        <div class="img_right">
          <div>
            <div class="red">*</div>
            <div class="text">营业执照：</div>
          </div>
          <div class="img">
            <img-upload class="img-upload" v-model="dataForm.businessLicense" />
          </div>
        </div>
      </div>
      <div class="dataForm_img">
        <div class="img_left">
          <div>
            <div class="red">*</div>
            <div class="text">企业法人身份证(正面)：</div>
          </div>
          <div class="img">
            <img-upload class="img-upload" v-model="dataForm.legalPersonCardF" />
          </div>
        </div>
        <div class="img_right">
          <div>
            <div class="red">*</div>
            <div class="text">企业法人身份证(反面)：</div>
          </div>
          <div class="img">
            <img-upload class="img-upload" v-model="dataForm.legalPersonCardB" />
          </div>
        </div>

      </div>
      <div class="dataForm_img">
        <div class="img_left">
          <div>
            <div class="red">*</div>
            <div class="text">食品生产许可证：</div>
          </div>
          <div class="img">
            <img-upload class="img-upload" v-model="dataForm.foodProductionPermit" />
          </div>
        </div>
        <div class="img_right">
          <div>
            <div class="red">*</div>
            <div class="text">商标注册证：</div>
          </div>
          <div class="img">
            <img-upload class="img-upload" v-model="dataForm.tradeMarkLicense" />
          </div>
        </div>
      </div>
      <div class="dataForm_img">
        <div class="img_left">
          <div>
            <div class="red">*</div>
            <div class="text">销售授权书：</div>
          </div>
          <div class="img">
            <img-upload class="img-upload" v-model="dataForm.marketingAuth" />
          </div>
        </div>
        <div class="img_right">
          <div>
            <div class="red">*</div>
            <div class="text">食品经营许可证：</div>
          </div>
          <div class="img">
            <img-upload class="img-upload" v-model="dataForm.foodBusinessLicense" />
          </div>
        </div>
      </div>
      <div class="dataForm_img">
        <div class="img_left">
          <div>
            <div class="red">*</div>
            <div class="text">生产单位营业执照：</div>
          </div>
          <div class="img">
            <img-upload class="img-upload" v-model="dataForm.licenseProductionUnit" />
          </div>
        </div>
        <div class="img_right">
          <div>
            <div class="red">*</div>
            <div class="text">质检报告：</div>
          </div>
          <div class="img">
            <img-upload class="img-upload" v-model="dataForm.qualityInspectReport" />
          </div>
        </div>
      </div>
      <div class="dataForm_img">
        <div class="img_left">
          <div>
            <div class="red">*</div>
            <div class="text">一般纳税人资格证：</div>
          </div>
          <div class="img">
            <img-upload class="img-upload" v-model="dataForm.taxpayerQualiCert" />
          </div>
        </div>
      </div>
      <el-form-item label="是否含进口商品:" prop="importedGoods">
        <span style="font-size: 18px;" v-if="this.dataForm.importedGoods == 1">是</span>
        <span style="font-size: 18px;" v-if="this.dataForm.importedGoods == 0">否</span>
      </el-form-item>
      <div v-if="this.dataForm.importedGoods == 1">
        <div class="dataForm_img is_imported">
          <div class="img_left">
            <div>
              <div class="red">*</div>
              <div class="text">委托进口协议：</div>
            </div>
            <div class="img">
              <img-upload class="img-upload" v-model="dataForm.entrustedImportAgreement" />
            </div>
          </div>
          <div class="img_right">
            <div>
              <div class="red">*</div>
              <div class="text">报关单：</div>
            </div>
            <div class="img">
              <img-upload class="img-upload" v-model="dataForm.customsDeclaration" />
            </div>
          </div>
        </div>
        <div class="dataForm_img">
          <div class="img_left">
            <div>
              <div class="red">*</div>
              <div class="text">入镜检验检疫：</div>
            </div>
            <div class="img">
              <img-upload class="img-upload" v-model="dataForm.entryInspectQuarantine" />
            </div>
          </div>
        </div>
      </div>

      <el-form-item>
        <el-button size="medium" type="primary" v-if="this.dataForm.status==0 && this.dataForm.name !== ''" @click="update1(dataForm.wineryId)">同意</el-button>
        <el-button size="medium" v-if="this.dataForm.status==0 && this.dataForm.name !== ''" @click="update_1(dataForm.wineryId)">拒绝</el-button>
      </el-form-item>
    </el-form>
  </div>


</template>

<script>
  import * as api from '@/api/winery/winery'
  import * as api_s from '@/api/winery/audit' //获取酒企审核详情
  import ImgUpload from './ImgUpload/index.vue'
  export default {
    components: {
      ImgUpload
    },
    data() {
      return {
        dataForm: {
          status: '',
          name: '',
          legalPerson: '',
          linkman: '',
          contactWay: '',
          basicAccount: '', //基础账户信息
          importedGoods: '',
          businessLicense: '',
          legalPersonCardF: '',
          legalPersonCardB: '',
          foodProductionPermit: '',
          tradeMarkLicense: '',
          marketingAuth: '',
          foodBusinessLicense: '',
          licenseProductionUnit: '',
          qualityInspectReport: '',
          taxpayerQualiCert: '',
          entrustedImportAgreement: '',
          customsDeclaration: '',
          entryInspectQuarantine: '',
          wineryId: '',
          source:'',
          opinion:'' ,//审核原因
          createTime:''//提交时间
        }
      }
    },
    created() {
      // 获取上页面跳转路由参数
      console.log(this.$route.query)
      this.dataForm.wineryId = this.$route.query.wineryId
    },
    mounted() {
      this.getwineryDetail()
      this.getWinery_audit()
    },
    methods: {
      //获取酒企审核详情
      getWinery_audit() {
        api_s.winery_audit(
          this.dataForm.wineryId
        ).then(data => {
          console.log("审核原因")
          console.log(data)
          console.log("审核原因")
          this.dataForm.opinion = data.opinion
        })
      },
      // 更新审核状态 同意
      update1(wineryId) {
        api.updateStatus({
          wineryId: wineryId,
          status: 1,
          wineryStatus: 1
        }).then(data => {
          this.$message({
            message: '成功！',
            type: 'success'
          });
          // this.$nextTick(function() {
          //   this.pageQuery.status = 1
          // })

        })
      },
      // 更新审核状态 拒绝
      update_1(wineryId) {
        //弹窗拒绝理由
        this.$prompt('拒绝理由', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
        }).then(({
          value
        }) => {
          var opinion = value
          console.log(value)
          console.log(opinion)
          api.updateStatus({
            wineryId: wineryId,
            status: -1,
            wineryStatus: 1,
            opinion: opinion
          }).then(data => {
            this.$message({
              message: '已拒绝！',
              type: 'success'
            });
            this.$router.go(0)
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '取消输入'
          });
        });
      },
      getwineryDetail() {
        if (this.dataForm.wineryId) {
          api.winery(this.dataForm.wineryId).then(data => {
            console.log('kkkkkkkkk')
            console.log(data)
            console.log('kkkkkkkkk')
            this.dataForm.createTime = data.createTime
            this.dataForm.name = data.name
            this.dataForm.legalPerson = data.legalPerson
            this.dataForm.linkman = data.linkman
            this.dataForm.contactWay = data.contactWay
            this.dataForm.importedGoods = data.importedGoods
            this.dataForm.basicAccount = data.basicAccount
            this.dataForm.businessLicense = data.businessLicense
            this.dataForm.legalPersonCardF = data.legalPersonCardF
            this.dataForm.legalPersonCardB = data.legalPersonCardB
            this.dataForm.foodProductionPermit = data.foodProductionPermit
            this.dataForm.licenseProductionUnit = data.licenseProductionUnit
            this.dataForm.qualityInspectReport = data.qualityInspectReport
            this.dataForm.taxpayerQualiCert = data.taxpayerQualiCert
            this.dataForm.tradeMarkLicense = data.tradeMarkLicense
            this.dataForm.marketingAuth = data.marketingAuth
            this.dataForm.foodBusinessLicense = data.foodBusinessLicense
            this.dataForm.entrustedImportAgreement = data.entrustedImportAgreement
            this.dataForm.customsDeclaration = data.customsDeclaration
            this.dataForm.entryInspectQuarantine = data.entryInspectQuarantine
            this.dataForm.tradeMarkLicense = data.tradeMarkLicense
            this.dataForm.status = data.status
            this.dataForm.source = data.source

          })
        } else {
          console.log('进入wwwwwwwwwwwwwww加载页面数据')
        }

      },
      back() {
        this.$router.back()
      }
    }
  }
</script>

<style lang="scss" scoped>
  //输入数字
  ::v-deep input::-webkit-outer-spin-button,
  ::v-deep input::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
  }

  ::v-deep input[type='number'] {
    -moz-appearance: textfield !important;
  }

  .main {
    margin: 30px 500px 50px 50px;

    .main_head {
      font-weight: bold;
      font-size: 20px;
      margin-bottom: 50px;
    }

    .dataForm {

      // 输入酒企信息
      .dataForm_flex {
        display: flex;
        justify-content: space-between;

        .auditD {
          color: #606266;
          font-size: 17px;
          font-weight: 400;
        }

        .form_item {
          width: 400px;
        }
      }

      // 上传照片
      .dataForm_img {
        margin-bottom: 50px;
        margin-right: 100px;
        display: flex;
        justify-content: space-between;

        .img_left {
          margin-right: 200px;
        }

        .red {
          color: red;
          padding-right: 3px;
          font-size: 14px;
          display: inline-block;
        }

        .text {
          display: inline-block;
          font-size: 14px;
          color: #606266
        }

        .img {
          display: inline-block;
          margin-left: 200px;

          .img-upload {
            ::v-deep .el-upload {
              background-color: #e0e1e1;

              .pic {
                display: block;
                width: 120px;
                height: 120px;
                padding: 2px;
                border-radius: 6px;
              }
            }
          }
        }
      }
    }
  }
</style>
